package com.dm.cloud.auth.mapper;

import com.dm.cloud.tkmybatis.service.BaseMapper;
import com.dm.cloud.auth.common.po.AuthPermission;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
   * @author hcx
   * @type AuthPermissionMapper.java
   * @desc AuthPermission mapper
   */

@Mapper
public interface AuthPermissionMapper extends BaseMapper<AuthPermission> {

    @Select("<script>" +
            " select * from T_AUTH_PERMISSION " +
            " where " +
            " code in (" +
            "   select permission_id from t_auth_role_permission where role_id in " +
            "   <foreach collection=\"roleIds\" open=\"(\" close=\")\" separator=\",\" item=\"item\" index=\"index\"> " +
            "      #{item} " +
            "   </foreach>" +
            "   )" +
            "</script>")
    List<AuthPermission> findByRoleIds(@Param("roleIds") List<String> roleIds);
}
